package com.ddone.demo.mapper;

import com.ddone.demo.bean.Emp;
import com.ddone.demo.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

/**
 * @author ddone
 * @date 2024/3/18-23:39
 */
public class MybatisAnnotationTest {
    private SqlSession sqlSession;
    private EmpAnnotation mapper;
    @Before
    public void init() {
        sqlSession = MybatisUtil.openAutoSession();
        mapper = sqlSession.getMapper(EmpAnnotation.class);
    }
    @Test
    public void testAnno(){
        List<Emp> empList = mapper.selectAll();
        System.out.println(empList);

        Emp emp = mapper.selectEmpById(4);
        System.out.println("emp = " + emp);
    }
    @After
    public void destroy() {
        sqlSession.close();
    }
}
